package com.cat.chapter042;

/**
 * @author cat
 * @description 判断一个数字是否是若干数量(数量>1)的连续正整数的和
 * @create 2025/7/11 09:11
 * @since JDK17
 */

public class Solution03 {
    public static boolean f(int n) {
        for (int i = 1; i < n; i++) {
            int sum = i;
            for (int j = i; j < n; j++, sum += j) {
                if (sum > n) {
                    break;
                }
                if (sum == n) {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean g(int n) {
        return (n & (n - 1)) != 0;
    }
    // 算法 : 输入 -> 处理 -> 输出
    public static void main(String[] args) {
        for (int i = 1; i < 200; i++) {
            System.out.println(i + " " + f(i));
            System.out.println(i + " " + g(i));
        }
    }
}
